<template>
  <a-config-provider :locale="locale">
    <div id="app">
      <router-view />
    </div>
  </a-config-provider>
</template>

<script>
import zhCN from 'ant-design-vue/lib/locale-provider/zh_CN'
import { AppDeviceEnquire } from '@/utils/mixin'
import { checkStatus } from '@/api/home/index'
import getters from '@/store/getters'

export default {
  mixins: [AppDeviceEnquire],
  data() {
    return {
      locale: zhCN,
      timer: null
    }
  },
  computed: {
    token() {
      return this.$store.getters.token
    }
  },
  watch: {
    token: {
      handler(newValue) {
        if (newValue) {
          this.checkStatus()
          this.timer = setInterval(() => {
            this.checkStatus()
          }, 60000)
        }
      },
      immediate: true
    }
  },
  mounted() {
    console.log('mounted')
  },
  beforeDestroy() {
    clearInterval(this.timer)
  },
  methods: {
    async checkStatus() {
      await checkStatus()
    }
  }
}
</script>

<style>
.ant-message {
  z-index: 9999 !important;
}
</style>
